package com.qfedu.mtl.service.impl;

import com.qfedu.mtl.dao.GoodDao;
import com.qfedu.mtl.dao.impl.GoodDaoImpl;
import com.qfedu.mtl.entity.Good;
import com.qfedu.mtl.query.GoodQuery;
import com.qfedu.mtl.service.GoodService;
import com.qfedu.mtl.util.page.Pager;

import java.util.List;

/**
 * @Date 2023/9/26 17:45
 */
public class GoodServiceImpl implements GoodService {

    private GoodDao goodDao=new GoodDaoImpl();

    @Override
    public Pager<Good> findPage(Integer page, Integer size, GoodQuery query) {
        List<Good> list=goodDao.selectData(page,size,query);
        Integer total=goodDao.selectTotal(query);
        Pager<Good> pager=new Pager<>(list,page,size,total);
        return pager;

    }

    @Override
    public Good findById(Integer id) {
        return goodDao.selectById(id);
    }

    @Override
    public void save(Good good) {
        goodDao.insert(good);
    }

    @Override
    public void update(Good good) {
        goodDao.update(good);
    }

    @Override
    public void delete(Integer id) {
        goodDao.delete(id);
    }

    @Override
    public void deleteBatch(List<Integer> ids) {
        goodDao.deleteBatch(ids);
    }
}
